﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MediaBrowser.Library.Persistance;
using System.IO;
using System.Globalization;
using MediaBrowser.Library.Extensions;
using MediaBrowser.Library.Configuration;
using MediaBrowser.Library.Localization;
using MediaBrowser.Library.Logging;

//***************************************************************************************************
//  This class is used to extend the string data used by MB.  It is localizable.
//  The most common use will be to provide description strings for config options.  To do this
//  define public string properties that are named the same as the label text of your options on your
//  config panel +desc.  A couple of examples have been generated by the template.
//***************************************************************************************************
namespace Subdued
{
    [Serializable]
    public class MyStrings : LocalizedStringData
    {
        const string VERSION = "1.0024"; //this is used to see if we have changed and need to re-save

        // MCML: [Application.LocalStrings.#StringName!cor:String]

        //these are our strings keyed by property name
        public string OrientationStr = "Orientation";

        public string HourStr = "Hour";
        public string HoursStr = "Hours";
        public string NoAvailOptions = "No Available Options";
        public string MovieStr = "Movie";
        public string MoviesStr = "Movies";
        public string SeriesStr = "Series";
        public string SeriesPluralStr = "Series";
        public string SeasonStr = "Season";
        public string SeasonsStr = "Seasons";
        public string EpisodeStr = "Episode";
        public string EpisodesStr = "Episodes";
        public string ItemStr = "Item";
        public string ItemsStr = "Items";
        public string ArtistStr = "Artist";
        public string ArtistsStr = "Artists";
        public string AlbumStr = "Album";
        public string AlbumsStr = "Albums";
        public string SongStr = "Song";
        public string SongsStr = "Songs";
        public string ConsoleStr = "Console";
        public string ConsolesStr = "Consoles";
        public string GameStr = "Game";
        public string GamesStr = "Games";
        public string PlayerStr = "Player";
        public string PlayersStr = "Players";
        public string TrailerStr = "Trailer";
        public string TrailersStr = "Trailers";
        public string ChannelStr = "Channel";
        public string ChannelsStr = "Channels";

        public string QuickPlayStr = "Quick Play";
        public string QueueAll = "Queue All";

        public string LeftRightStr = "Left/Right";
        public string UpDownStr = "Up/Down";
        public string FwdRewStr = "Fwd/Rew";
        public string PgUpDownStr = "PgUp/PgDown";
        public string ChUpDownStr = "Ch+/Ch-";

        public string RecentAdditions = "Recent Additions";
        public string NoRecentAdditions = "No Recent Additions";
        public string RecentUnwatched = "Recent Unwatched";
        public string NoRecentUnwatched = "No Recent Unwatched";
        public string RecentlyWatched = "Recently Watched";
        public string NoRecentlyWatched = "No Recently Watched";

        public string OverviewStr = "Overview";
        public string CastStr = "Cast";
        public string DetailsStr = "Details";

        public string VideoFormatLabel = "Video Format";
        public string VideoResolutionLabel = "Video Resolution";
        public string SubtitlesLabel = "Subtitles";
        public string AudioFormatLabel = "Audio Format";
        public string AudioStreamsLabel = "Audio Streams";
        public string LastWatchedLabel = "Last Watched";
        public string NoMediaDetailsLabel = "No Media Details";

        public string OptionsLabel = "Options";
        public string ConfigureLabel = "Configure";
        public string ViewStyleLabel = "View Style";
        public string ViewOptionsLabel = "View Options";
        public string SortByLabel = "Sort By";
        public string GroupByLabel = "Group By";
        public string LiveLayoutLabel = "Live Layout";

        public string ShowAsTextLabel = "Show As Text";
        public string ShowBackdropLabel = "Show Backdrop";
        public string ShowBackdropOverlayLabel = "Show Backdrop Overlay";
        public string ShowNPVLabel = "Show Now Playing View";
        public string ShowTextBGLabel = "Show Text Background";
        public string ShowThumbsBGLabel = "Show Thumbs Background";
        public string ShowTopPanelLabel = "Show Top Panel";
        public string ShowSelItemInfoLabel = "Show Selected Item Info";
        public string WrapItemListLabel = "Wrap Item List";
        public string FolderDisplayLabel = "Folder Display";
        public string SelectedInfoStyleLabel = "Selected Info Style";
        public string RotateBackdropsLabel = "Rotate Backdrops";
        public string EnableWatchedIndicatorsLabel = "Enable (Un)Watched Indicators";

        public string LockConfigLabel = "Lock Configuration";
        public string UnlockConfigLabel = "Unlock Configuration";

        public string LiveLayoutMessage = "Press 'Select' or 'Back' to exit Live Layout";

        public string GeneralOptionsLabel = "General Options";
        public string ThemeStyleLabel = "Theme Style";
        public string MediaInfoIconsSetLabel = "MediaInfo Icons Set";
        public string TopPanelStyleLabel = "Top Panel Style";
        public string StarRatingStyleLabel = "Star Rating Style";
        public string NowPlayingStyleLabel = "Now Playing Style";
        public string ScrollSpeedLabel = "List Scroll Speed";
        public string ThumbSpacingLabel = "Thumb Spacing";
        public string ThumbGrowLabel = "Thumb Grow %";
        public string WatchedIndicatorPositionLabel = "(Un)Watched Indicator";
        public string CAAdjustmentLabel = "CoverArt Adjustment";
        public string UnselectedThumbAlphaLabel = "Unselected Thumb Alpha %";
        public string GraduatedAlphaLabel = "Graduated Thumb Alpha";
        public string ColorizeStudioImagesLabel = "Colorize Studio Images";
        public string ColorizeRatingsImagesLabel = "Colorize Ratings Images";
        public string ColorizeCustomRatingsImagesLabel = "Colorize Custom Ratings Images";
        public string ColorizePosterOverlayImagesLabel = "Colorize Poster Overlay Images";
        public string ShowMasterPCIconLabel = "Show Master PC Icon";
        public string ShowClockConfigAtTopLabel = "Show Clock/Config at Top";
        public string ShowEndTimeLabel = "Show End Time";
        public string ShowPrevNextButtonsLabel = "Show Prev/Next Buttons";
        public string ShowIndexOfCountLabel = "Selected Item 'Index of Count'";
        public string ShowQuickPlayLabel = "Show Quick Play Action";

        public string ShowNewItemIndicatorLabel = "Show New Item Indicator";
        public string MediaInfoIconDisplayLabel = "Media Info Icons";
        public string ShowMediaInfoMediaLabel = "Show Media Type";
        public string ShowMediaInfoVideoLabel = "Show Video Codec";
        public string ShowMediaInfoHDLabel = "Show HD Type";
        public string ShowMediaInfoAspectLabel = "Show Aspect Ratio";
        public string ShowMediaInfoAudioLabel = "Show Audio Codec";
        public string ShowMediaInfoAudioChannelLabel = "Show Audio Channels";
        public string ShowMediaInfoMovieRatingLabel = "Show Movie Rating";

        public string ThemeStyleLabelDesc = "Choose the active theme style from a list of installed styles";
        public string MediaInfoIconsSetLabelDesc = "Choose the MediaInfo icons set to use; Custom sets prevent overwriting of ImagesByName/MediaInfo/Subuded folder; Mono sets are colorized by the active theme style";
        public string TopPanelStyleLabelDesc = "Display the title/status area using double panels, a single panel, no panels, or turn off completely";
        public string StarRatingStyleLabelDesc = "Display the selected item's star rating as a Star Graph, numeric, or turn off";
        public string NowPlayingStyleLabelDesc = "Display the 'Now Playing View' as a small window, full screen backdrop, or turn off";
        public string ScrollSpeedLabelDesc = "Change speed of item list scrolling: Slow, Medium, or Fast";
        public string ThumbSpacingLabelDesc = "Defines the spacing used between thumbnails";
        public string ThumbGrowLabelDesc = "Defines the % of the original thumbnail size to grow the focused thumbnail by";
        public string WatchedIndicatorPositionLabelDesc = "Defines the location of the watched/unwatched indicator overlay";
        public string CAAdjustmentLabelDesc = "Defines an offset to adjust the thumbnail focus frame and dim overlay by to account for CoverArt treatment, or posters that do not reach edge-to-edge";
        public string UnselectedThumbAlphaLabelDesc = "Defines the alpha % to be used for unselected thumbnails; 0% = fully transparent, 100% = fully visible";
        public string GraduatedAlphaLabelDesc = "For Coverflow and Thumb Strip view styles, enables decreasing alpha the further away from the selected item (if Unselected Thumb Alpha is less than 100%)";
        public string ColorizeStudioImagesLabelDesc = "If enabled, uses the style-defined colorization for studio images; if disabled, leaves their colors as-is";
        public string ColorizePosterOverlayImagesLabelDesc = "If enabled, uses the style-defined colorization for poster overlay images; if disabled, leaves their colors as-is";
        public string ColorizeRatingsImagesLabelDesc = "If enabled, uses the style-defined colorization for ratings images; if disabled, leaves their colors as-is";
        public string ColorizeCustomRatingsImagesLabelDesc = "If enabled, uses the style-defined colorization for custom ratings images; if disabled, leaves their colors as-is";
        public string ShowMasterPCIconLabelDesc = "Enables lock icon that allows Parental Controls to be turned off globally, or re-enabled";
        public string ShowClockConfigAtTopLabelDesc = "Shows the clock, busy indicator, Parental Controls lock, return to Now Playing, and Config buttons at the top; not recommended if using a mouse for navigation";
        public string ShowEndTimeLabelDesc = "Enables the display of the item's end time after its running time";
        public string ShowPrevNextButtonsLabelDesc = "Enables the display of the First (|<), Prev (<), Next (>), and Last (>|) buttons on the item details page; turning this off will not disable the keyboard/remote shortcuts for these functions";
        public string ShowIndexOfCountLabelDesc = "Enables the display of the selected item's index out of the total item count in the breadcrumb area";
        public string ShowNewItemIndicatorLabelDesc = "Enables the display of a 'NEW' indicator for items that are in a collection's recently added list";
        public string ShowQuickPlayLabelDesc = "Enables the Quick Play action on the item details view allowing intros to be bypassed";

        public string ShowMediaInfoMediaLabelDesc = "Enables the display of the Media Info Media Type icon";
        public string ShowMediaInfoVideoLabelDesc = "Enables the display of the Media Info Video Codec icon";
        public string ShowMediaInfoHDLabelDesc = "Enables the display of the Media Info HD Type icon";
        public string ShowMediaInfoAspectLabelDesc = "Enables the display of the Media Info Aspect Ratio icon";
        public string ShowMediaInfoAudioLabelDesc = "Enables the display of the Media Info Audio Codec icon";
        public string ShowMediaInfoAudioChannelLabelDesc = "Enables the display of the Media Info Audio Channels icon";
        public string ShowMediaInfoMovieRatingLabelDesc = "Enables the display of the Movie Rating icon";

        public string CoverWallOptionsLabel = "Cover Wall Options";
        public string CoverWallRootBackdropLabel = "Cover Wall Root Backdrop";
        public string CoverWallScreenSaverLabel = "Cover Wall Screen Saver";
        public string CoverWallScrollLabel = "Cover Wall Scroll";
        public string CoverWallRotationLabel = "Cover Wall Rotation";
        public string CoverWallScrollSpeedLabel = "Cover Wall Scroll Speed";
        public string CoverWallSSTimeoutLabel = "Cover Wall SS Timeout";

        public string CoverWallFoldersLabel = "Cover Wall Folders";
        public string CoverWallBackdropColumnLabel = "BD";
        public string CoverWallScreenSaverColumnLabel = "SS";

        public string CoverWallRootBackdropLabelDesc = "Enables the display of the Cover Wall as the backdrop for the root view (EHS or standard)";
        public string CoverWallScreenSaverLabelDesc = "Enabled the display of the Cover Wall as a screensaver";
        public string CoverWallScrollLabelDesc = "Change the scrolling direction of the Cover Wall: Left, Right, Up, or Down";
        public string CoverWallRotationLabelDesc = "Change the rotation of the Cover Wall, if enabled: None, To Back, or To Right";
        public string CoverWallScrollSpeedLabelDesc = "Change speed of Cover Wall scrolling: Crawl, Slow, Medium, or Fast";
        public string CoverWallSSTimeoutLabelDesc = "Set the idle time, in minutes, after which the Cover Wall Screen Saver will be displayed, if enabled";

        public string ViewRotationOptionsLabel = "View Rotation Options";
        public string CoverflowRotationLabel = "Coverflow Rotation";
        public string PosterRotationLabel = "Poster Rotation";
        public string ThumbRotationLabel = "Thumb Rotation";
        public string ThumbstripRotationLabel = "Thumb Strip Rotation";

        public string CoverflowRotationLabelDesc = "Change the rotation of Coverflow view style thumbnails: None, To Back, or To Right";
        public string PosterRotationLabelDesc = "Change the rotation of Poster view style thumbnails: None, To Back, or To Right";
        public string ThumbRotationLabelDesc = "Change the rotation of Thumb view style thumbnails: None, To Back, or To Right";
        public string ThumbstripRotationLabelDesc = "Change the rotation of Thumb Strip view style thumbnails: None, To Back, or To Right";

        public string EHSShowInfoLabel = "EHS Show Recent Info";
        public string EHSRALBackdropLabel = "EHS Show Recent Backdrop";
        public string EHSEpisodeThumbsLabel = "EHS Show Recent Episode Thumbs";
        public string EHSHListSizeLabel = "EHS Horizontal List Size";
        public string EHSThumbSizeLabel = "EHS Thumb Size";
        public string EHSRightLabel = "EHS Right %";
        public string EHSRALLeftLabel = "EHS Recent Left %";
        public string EHSRALPosLabel = "EHS Recent Position";
        public string RootCoverflowPosLabel = "Root Coverflow Position";
        public string RootDetailsRightLabel = "Root Details Right %";
        public string RootPosterTopLabel = "Root Poster Top %";

        public string ChildViewOptionsLabel = "Child View Options";
        public string ChildCoverflowPosLabel = "Child Coverflow Position";
        public string ChildDetailsTopLabel = "Child Details Top %";
        public string ChildDetailsSepLabel = "Child Details Separator %";
        public string ChildPosterTopLabel = "Child Poster Top %";
        public string ChildThumbTopLabel = "Child Thumb Top %";
        public string ChildThumbSepLabel = "Child Thumb Separator %";
        public string ChildThumbStripTopLabel = "Child Thumb Strip Top %";
        public string ChildThumbShowBannerLabel = "Child Thumb View Show Banner";
        public string ChildThumbMiniBackdropLabel = "Child Thumb Mini Backdrop";
        public string ChildThumbStripMiniBackdropLabel = "Child Thumb Strip Mini Backdrop";
        public string ChildSeasonEpisodeOverlayLabel = "Child Season/Episode Overlay";

        public string ChildThumbShowBannerLabelDesc = "Enables the display of a banner image, if available, in the item information panel on a child Thumb view";
        public string ChildThumbMiniBackdropLabelDesc = "Enables the display of a small backdrop image in the item information panel on a child Thumb view";
        public string ChildThumbStripMiniBackdropLabelDesc = "Enables the display of a small backdrop image in the item information panel on a child Thumb Strip view";
        public string ChildSeasonEpisodeOverlayLabelDesc = "Enables the display, for episodes, of a smaller episode thumbnail on top of a full-sized season poster on a child Details view or the Item Details page";

        public string ConfigRestartMessage = "Changes require a restart";

        public string IndexOfCountFormat = "{0} of {1}";

        public MyStrings () //for the serializer
        {
            Version = VERSION;
        }

        public static MyStrings FromFile (string file)
        {
            MyStrings s = new MyStrings ();
            XmlSettings<MyStrings> settings = XmlSettings<MyStrings>.Bind (s, file);

            Logger.ReportInfo ("Using String Data from " + file);

            if (VERSION != s.Version)
            {
                DateTime    now = DateTime.Now;
                string      backupFile = Path.Combine (Path.GetDirectoryName (file),
                                                       Path.GetFileNameWithoutExtension (file) +
                                                            "_" +
                                                            now.Year.ToString () +
                                                            now.Month.ToString ("D2") +
                                                            now.Day.ToString ("D2") +
                                                            now.Hour.ToString ("D2") +
                                                            now.Minute.ToString ("D2") +
                                                            now.Second.ToString ("D2") +
                                                            ".BAK");

                Logger.ReportInfo ("Subdued - Backing up strings file to: " + backupFile);

                if (File.Exists (backupFile))
                    File.Delete (backupFile);

                File.Move (file, backupFile);

                s = new MyStrings ();
                settings = XmlSettings<MyStrings>.Bind (s, file);
            }
            return s;
        }
    }
}
